﻿using System;
using System.Collections.Generic;
using System.Text;
using PersistentObjects;

namespace PocketPatients
{
    public class Visit : Persistent
    {
        public Visit()
            : base()
        {
        }

        Patient patient = null;
        public Patient Patient
        {
            get { return patient; }
            set { patient = value; }
        }

        DateTime date = DateTime.Now.Date;
        public DateTime Date
        {
            get { return date; }
            set { date = value.Date; }
        }
    }

    public class Patient : Persistent
    {
        public Patient():base()
        {

        }

        public PersistentList<Visit> Visits
        {
            get {return GetRelation<Visit>();}
        }
        string lastName = "";
        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }

        string firstName = "";
        public string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }

        public string FullName
        {
            get 
            {
                if (LastName == null && FirstName == null)
                    return "UNKNOWN";
                else if (FirstName == null)
                    return LastName;
                else if (LastName == null)
                    return FirstName;
                else
                    return FirstName == "" ? LastName : LastName + ", " + FirstName; 
            }
        }

        DateTime birthDay = DateTime.Now;
        public DateTime BirthDay
        {
            get { return birthDay; }
            set { birthDay = value; }
        }

        public int Age
        {
            get 
            {
                if (BirthDay < DateTime.Today)
                    return ((DateTime.Today - birthDay).Days) / 365;
                else
                    return -1;
            }
        }

        string tel = "";
        public string Telephone
        {
            get { return tel; }
            set { tel = value; }
        }

        string mobile = "";
        public string Mobile
        {
            get {return mobile;}
            set {mobile = value;}
        }

        string workphone = "";
        public string WorkPhone
        {
            get { return workphone;}
            set {workphone = value;}
        }

        string address = "";
        public string Address
        {
            get { return address;}
            set { address = value;}
        }

        System.Drawing.Image photo = new System.Drawing.Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
        public System.Drawing.Image Photograph
        {
            get { return photo; }
            set { photo = value; }
        }
    }
}
